package cn.com.guage.dtm.design.pattern.singleton;

/**
 * 1. 特点：类加载时立即初始化，线程安全，无需同步。
 * 2. 缺点：不支持延迟加载，可能造成资源浪费
 */
public class 单例模式_饿汉式 {

    public static void main(String[] args) {
        EagerSingleton eagerSingleton = EagerSingleton.getInstance();
        eagerSingleton.showMessage();
    }
}
class EagerSingleton{
    private static  EagerSingleton instance = new EagerSingleton();
    private EagerSingleton(){

    }
    public static EagerSingleton getInstance(){
        return instance;
    }
    public void showMessage() {
        System.out.println("单例模式_饿汉式");
    }
}